<?php
/**
 * 
 * @author yuxun
 *
 */

class ModVersionUpdate extends Model {

    protected $table = 'version_update';

    // 表名
    public function tableName(){
        return $this->table;
    }

    public static function model($className=__CLASS__){
        return parent::model($className);
    }

    public function getDbConnection(){
        return Yii::app()->dbOss;
    }

    public function addmuch($params){
    	$result = $this->getDbConnection()->multiInsert($params, $this->table, FALSE);
    	return $result;
    }
    
    public function getVersionUpdate($serverIds){
    	$sql = "SELECT * from version_update WHERE server_id in ({$serverIds})";
    	$result = $this->getDbConnection()->getAll($sql, $args);
    	return $result;
    }
    
    public function deleteForServerId($serverIds){
    	$sql = "delete from version_update WHERE server_id in ({$serverIds})";
    	$result = $this->getDbConnection()->execute($sql, $args);
    	return $result;
    }
    
    public function select($game,$is_automatic,$update_time){
    	$sql = "select oss_api,ip,develop_id,server_id,version_is_automatic,version_update_time,vu.id as id,server_name,update_packet  ";
        $sql .= " FROM server as s INNER JOIN version_update as vu on vu.server_id = s.id ";
        $sql .= " WHERE game = '{$game}' and version_is_automatic = {$is_automatic} and version_update_time = {$update_time}";
        $result = $this->getDbConnection()->execute($sql);
        return $result;
    }
    
    
    
    
} 